<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:sec="http://www.springframework.org/security/tags"
	xmlns:p="http://primefaces.org/ui">

	<h:panelGroup style="padding-left: 30px;" layout="block">
		<h:form>
			<div class="juice-collection-action">
				<i class="icon-plus"></i>
				<h:commandButton styleClass="btn btn-link"
					value="Créer une collection">
					<f:setPropertyActionListener target="#{C_COLLECTION.name}" value=""></f:setPropertyActionListener>
					<f:setPropertyActionListener target="#{C_COLLECTION.comment}"
						value=""></f:setPropertyActionListener>
					<f:setPropertyActionListener target="#{C_COLLECTION.displayDetail}"
						value="true"></f:setPropertyActionListener>
					<f:setPropertyActionListener target="#{C_COLLECTION.newCollection}"
						value="true"></f:setPropertyActionListener>
				</h:commandButton>
			</div>
			<ui:repeat var="c" value="#{C_COLLECTION.paginator.current}" varStatus="s">
				<p class="lead">#{c.name}</p>
				<p>#{c.comment}</p>
				<p class="muted">
					<h:outputText value="Créee le " />
					<h:outputText value="#{c.created}">
						<f:convertDateTime timeStyle="long" />
					</h:outputText>
					<ui:fragment rendered="#{c.modified ne c.created}">
						<br />
						<h:outputText value="Ajustée le " />
						<h:outputText value="#{c.modified}">
							<f:convertDateTime timeStyle="long" />
						</h:outputText>
					</ui:fragment>
				</p>

				<div class="juice-collection-action">
					<i class="icon-pencil"></i>
					<h:commandButton styleClass="btn btn-link" value="Editer">
						<f:setPropertyActionListener target="#{C_COLLECTION.name}"
							value="#{c.name}"></f:setPropertyActionListener>
						<f:setPropertyActionListener target="#{C_COLLECTION.comment}"
							value="#{c.comment}"></f:setPropertyActionListener>
						<f:setPropertyActionListener
							target="#{C_COLLECTION.displayDetail}" value="true"></f:setPropertyActionListener>
						<f:setPropertyActionListener
							target="#{C_COLLECTION.newCollection}" value="false"></f:setPropertyActionListener>
						<f:setPropertyActionListener
							target="#{C_COLLECTION.currentCollection}" value="#{c}"></f:setPropertyActionListener>
					</h:commandButton>
					<i class="icon-trash"></i>
					<h:commandButton styleClass="btn btn-link" value="Supprimer" disabled="#{fn:length(c.recipes) gt 0}" action="#{C_COLLECTION.remove}">
						<f:setPropertyActionListener
							target="#{C_COLLECTION.displayDetail}" value="false"></f:setPropertyActionListener>
						<f:setPropertyActionListener
							target="#{C_COLLECTION.newCollection}" value="false"></f:setPropertyActionListener>
						<f:setPropertyActionListener
							target="#{C_COLLECTION.currentCollection}" value="#{c}"></f:setPropertyActionListener>
					</h:commandButton>
				</div>
			</ui:repeat>
			<h:panelGroup rendered="#{C_COLLECTION.paginator.psize > 1}"
				layout="block">
				<div class="controls">
					<h:commandButton
						styleClass="#{C_COLLECTION.previous ? 'btn' : 'btn disabled'}"
						value="Précédent" action="#{C_COLLECTION.getPrevious}"
						disabled="#{! C_COLLECTION.previous}" />
					<strong> <h:outputText style="margin-left: 20px; margin-right: 20px;"  
							value="#{C_COLLECTION.paginator.displayIndex} / #{C_COLLECTION.paginator.psize}" />
					</strong>
					<h:commandButton
						styleClass="#{C_COLLECTION.next ? 'btn' : 'btn disabled'}"
						value="Suivant" action="#{C_COLLECTION.getNext}"
						disabled="#{! C_COLLECTION.next}" />
				</div>
			</h:panelGroup>
		</h:form>
	</h:panelGroup>


</ui:composition>
